//
//  Tookit.m
//  CllForIOS
//
//  Created by hongbo on 13-12-10.
//  Copyright (c) 2013年 aRui. All rights reserved.
//

#import "Tookit.h"

@implementation Tookit
+(void)clearCookies {
    NSArray * cookArray = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:[NSURL URLWithString:@"https://www.qyun88.com/"]];
    for (int i = 0; i < [cookArray count]; i++) {
        NSHTTPCookie *cookie = (NSHTTPCookie *)[cookArray objectAtIndex:i];
        [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
    }
    return;
}
+(NSString *)getUserCasheFileName {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *plistPath = [paths objectAtIndex:0];
    NSString *fileName = [NSString stringWithFormat:@"UserInfo"];
    return [plistPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.plist", fileName]];
}

+(NSMutableDictionary *)getUserCasheInfo {
    NSMutableDictionary *data = [[NSMutableDictionary alloc] initWithContentsOfFile:[Tookit getUserCasheFileName]];
    if (data == nil)
        data = [NSMutableDictionary new];
    return data;
}

+(void)saveUserCasheInfo:(NSMutableDictionary *)data {
    if (data)
        [data writeToFile:[Tookit getUserCasheFileName] atomically:YES];
    return;
}

+(UIAlertView *)showAlert:(NSString *)text delegate:(id)delegate buttonTitle:(NSString *)buttonTitle otherButtonTitles:(NSString *)otherButtonTitles tag:(int)tag {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:text delegate:delegate cancelButtonTitle:buttonTitle otherButtonTitles:otherButtonTitles, nil];
    alert.tag = tag;
    [alert show];
    return alert;
}
@end
